package com.sinoeyes.system.service.impl;

import java.util.List;

import com.sinoeyes.common.core.page.RestPageResult;
import com.sinoeyes.common.core.text.Convert;
import com.sinoeyes.common.vo.BaseVo;
import com.sinoeyes.system.filter.SysOperLogFilter;
import com.sinoeyes.system.mapper.SysOperLogMapper;
import com.sinoeyes.system.po.SysOperLogPo;
import com.sinoeyes.system.service.ISysOperLogService;
import com.sinoeyes.system.vo.SysOperLogVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 操作日志 服务层处理
 * 
 * @author ruoyi
 */
@Service
public class SysOperLogServiceImpl implements ISysOperLogService
{
    @Autowired
    private SysOperLogMapper operLogMapper;

    /**
     * 新增操作日志
     * 
     * @param operLog 操作日志对象
     */
    @Override
    public void insertOperlog(SysOperLogVo operLog)
    {
        operLogMapper.insertOperlog(BaseVo.copyVo2Po(operLog, SysOperLogPo.class));
    }

    /**
     * 查询系统操作日志集合
     * 
     * @param filter 操作日志对象
     * @return 操作日志集合
     */
    @Override
    public RestPageResult<SysOperLogVo> selectOperLogList(SysOperLogFilter filter)
    {
        filter.startPage();
        List<SysOperLogPo> sysOperLogPos = operLogMapper.selectOperLogList(filter);
        RestPageResult pageResult = filter.getPageResult(sysOperLogPos);
        return BaseVo.copyPo2Vo(pageResult, SysOperLogVo.class);

    }

    /**
     * 批量删除系统操作日志
     * 
     * @param ids 需要删除的数据
     * @return
     */
    @Override
    public int deleteOperLogByIds(String ids)
    {
        return operLogMapper.deleteOperLogByIds(Convert.toStrArray(ids));
    }

    /**
     * 查询操作日志详细
     * 
     * @param operId 操作ID
     * @return 操作日志对象
     */
    @Override
    public SysOperLogVo selectOperLogById(Long operId)
    {
        return BaseVo.copyPo2Vo(operLogMapper.selectOperLogById(operId), SysOperLogVo.class);
    }

    /**
     * 清空操作日志
     */
    @Override
    public void cleanOperLog()
    {
        operLogMapper.cleanOperLog();
    }
}
